package cn.wjdiankong.levideo.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;

public class RotateImageView extends CircularImageView{

	private RotateAnimation rotateAnimation;
	
	public RotateImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
		rotateAnimation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setDuration(5000);
        rotateAnimation.setRepeatCount(Animation.INFINITE);
        rotateAnimation.setRepeatMode(Animation.RESTART);
        rotateAnimation.setFillAfter(true);
        rotateAnimation.setInterpolator(new LinearInterpolator()); 
	}
	
	public void startRotate(){
		if(rotateAnimation != null){
			startAnimation(rotateAnimation);
		}
	}
	
	public void stopRotate(){
		if(rotateAnimation != null){
			clearAnimation();
		}
	}

}
